package com.niit.bc.util.web;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class RegularExpression {

    /**
     * 浮点类型
     */
    public boolean floatRegx(String number) {
        boolean flag = false;
        String regx = "^([+-]?)\\d*\\.\\d+$";
        Pattern pattern = Pattern.compile(regx);
        Matcher m = pattern.matcher(number);
        flag = m.matches();
        return flag;
    }

    /**
     * 正整数
     */
    public boolean numberRegx(String number) {
        boolean flag = false;
        String regx = "^[0-9]*[1-9][0-9]*$";
        Pattern pattern = Pattern.compile(regx);
        Matcher m = pattern.matcher(number);
        flag = m.matches();

        return flag;
    }

    /**
     * Email
     */
    public boolean emailRegx(String email) {
        boolean flag = false;
        String regx = "^\\w+((-\\w+)|(\\.\\w+))*\\@[A-Za-z0-9]+((\\.|-)[A-Za-z0-9]+)*\\.[A-Za-z0-9]+$";
        Pattern pattern = Pattern.compile(regx);
        Matcher m = pattern.matcher(email);
        flag = m.matches();
        return flag;
    }

    /**
     * 手机
     */

    public boolean mobileRegx(String mobile) {
        boolean flag = false;
        String regx = "^(13|15|18)[0-9]{9}$";
        Pattern pattern = Pattern.compile(regx);
        Matcher m = pattern.matcher(mobile);
        flag = m.matches();
        return flag;
    }

    /**
     * qq
     */
    public boolean qqRegx(String qq) {
        boolean flag = false;
        String regx = "^[1-9]*[1-9][0-9]*$";
        Pattern pattern = Pattern.compile(regx);
        Matcher m = pattern.matcher(qq);
        flag = m.matches();
        return flag;
    }
    /*public static void main(String []args) {
        RegularExpression a=new RegularExpression();
		System.out.println(a.floatRegx("12.0"));
		System.out.println(a.numberRegx("10"));
	}*/
}
